﻿using System;
using System.Collections.Generic;
using CoffeeBar.Webservice_Namespace;

namespace CoffeeBar.Models.Webservice_Access
{
    public class DataAccess
    {
        static WebService service = new WebService();
#region kiemtratontai
        public static bool kiemtratontai_BAN(Int32 MaBan)//kiem tra ton tai ban
        {
            return service.kiemtratontai_BAN(MaBan);
        }
        public static bool kiemtratontai_CA(Int32 MaCa)//kiem tra ton tai ca
        {
            return service.kiemtratontai_CA(MaCa);
        }
        public static bool kiemtratontai_CHUYENMUC(Int32 MaChuyenMuc)//kiem tra ton tai ca
        {
            return service.kiemtratontai_CHUYENMUC(MaChuyenMuc);
        }
        public static bool kiemtratontai_DATBAN(Int32 MaDatBan)//kiem tra ton tai dat ban
        {
            return service.kiemtratontai_DATBAN(MaDatBan);
        }
        public static bool kiemtratontai_DATHANG(Int32 MaDatHang)//kiem tra ton tai dat hang
        {
            return service.kiemtratontai_DATHANG(MaDatHang);
        }
#endregion
#region them
        public bool them_BAN(Int32 MaKhuVuc, Int32 SoGhe)//them ban
        {
            try
            {
                service.them_BAN(MaKhuVuc, SoGhe);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool them_CA(CoffeeBar.Webservice_Namespace.TimeSpan BatDau, CoffeeBar.Webservice_Namespace.TimeSpan KetThuc, float HeSoLuong)//them ca
        {
            try
            {
                service.them_CA(BatDau, KetThuc, HeSoLuong);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool them_CHUYENMUC(string TenChuyenMuc)//them chuyen muc
        {
            try
            {
                service.them_CHUYENMUC(TenChuyenMuc);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool them_DATBAN(DateTime NgayDat, CoffeeBar.Webservice_Namespace.TimeSpan ThoiGianBatDau, CoffeeBar.Webservice_Namespace.TimeSpan ThoiGianKetThuc)//them dat ban
        {
            try
            {
                service.them_DATBAN(NgayDat, ThoiGianBatDau, ThoiGianKetThuc);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool them_DATHANG(Int32 MaKH, Int32 MaNhanVien, string DiaChiGiao, DateTime ThoiGianDat, DateTime ThoiGianYeuCau, short TinhTrangGiao, short TinhTrangThanhToan)//them dat hang
        {
            try
            {
                service.them_DATHANG(MaKH, MaNhanVien, DiaChiGiao, ThoiGianDat, ThoiGianYeuCau, TinhTrangGiao, TinhTrangThanhToan);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }
        public bool them_LOAIHANG(string _tenloaihang)
        {
            try
            {
                service.them_LOAIHANG(_tenloaihang);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool them_HANGBAN(int maloaihang,string tenhang, int dongia,string gioithieu, int sanco, int diemdanhgia)
        {
            try
            {
                service.them_HANGBAN((Int32)maloaihang, tenhang, (long)dongia, gioithieu, (Int32)sanco, (short)diemdanhgia);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
#endregion
#region xoa
        public bool xoa_BAN(Int32 MaBan)//huy ban
        {
            try
            {
                service.xoa_BAN(MaBan);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool xoa_CA(Int32 MaCa)//huy ca
        {
            try
            {
                service.xoa_CA(MaCa);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool xoa_CHUYENMUC(Int32 MaChuyenMuc)//huy chuyen muc
        {
            try
            {
                service.xoa_CHUYENMUC(MaChuyenMuc);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool xoa_DATBAN(Int32 MaDatBan)//huy dat ban
        {
            try
            {
                service.xoa_DATBAN(MaDatBan);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool xoa_DATHANG(Int32 MaDatHang,DateTime TuNgay,DateTime DenNgay)//huy dat hang...theo ma dat hang....theo khoang thoi gian dat hang
        {
            try
            {
                service.xoa_DATHANG(MaDatHang,TuNgay,DenNgay);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool xoa_LOAIHANG(int maloaihang)
        {
            try
            {
                service.xoa_LOAIHANG(maloaihang);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool xoa_HANGBAN(Int32 id)
        {
            try
            {
                service.xoa_HANGBAN(id);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
#endregion
#region sua
        public bool sua_BAN(Int32 MaBan, Int32 MaKhuVuc, Int32 SoGhe)//sua ban
        {
            try
            {
                service.sua_BAN(MaBan, MaKhuVuc, SoGhe);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool sua_CA(Int32 MaCa, CoffeeBar.Webservice_Namespace.TimeSpan BatDau, CoffeeBar.Webservice_Namespace.TimeSpan KetThuc, float HeSoLuong)//sua ca
        {
            try
            {
                service.sua_CA(MaCa, BatDau, KetThuc, HeSoLuong);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool sua_CHUYENMUC(Int32 MaChuyenMuc, string TenChuyenMuc)//sua chuyen muc
        {
            try
            {
                service.sua_CHUYENMUC(MaChuyenMuc, TenChuyenMuc);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool sua_DATBAN(Int32 MaDatBan, DateTime NgayDat, CoffeeBar.Webservice_Namespace.TimeSpan ThoiGianBatDau, CoffeeBar.Webservice_Namespace.TimeSpan ThoiGianKetThuc)//sua dat ban
        {
            try
            {
                service.sua_DATBAN(MaDatBan, NgayDat, ThoiGianBatDau, ThoiGianKetThuc);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }

        public bool sua_DATHANG(Int32 MaDatHang, Int32 MaKH, Int32 MaNhanVien, string DiaChiGiao, DateTime ThoiGianDat, DateTime ThoiGianYeuCau, short TinhTrangGiao, short TinhTrangThanhToan)//sua dat hang
        {
            try
            {
                service.sua_DATHANG(MaDatHang, MaKH, MaNhanVien, DiaChiGiao, ThoiGianDat, ThoiGianYeuCau, TinhTrangGiao, TinhTrangThanhToan);
            }
            catch (System.Exception e)
            {
                return false;
            }
            return true;
        }
        public bool sua_LOAIHANG(string id, string item_name)
        {
            try
            {
                service.sua_LOAIHANG(id, item_name);               

            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
        public bool sua_HANGBAN(Int32 MaHang,Int32 MaLoaiHang, string TenHang, Int32 DonGia, string GioiThieu, int SanCo,int DiemDanhGia)
        {
            try
            {
                service.sua_HANGBAN((long)MaHang, (int)MaLoaiHang, TenHang, (long)DonGia, GioiThieu, (int)SanCo, (short)DiemDanhGia);
            }
            catch (System.Exception ex)
            {
                return false;
            }
            return true;
        }
#endregion
#region laydanhsach
        public static BAN[] laydanhsach_BAN(Int32 MaBan)// lay danh sach ban:neu ton tai MaBan se return Ban do.Neu ko ton tai se tra ve tat ca cac ban
        {
            return service.laydanhsach_BAN(MaBan);
        }
        public CA[] laydanhsach_CA(Int32 MaCa)//lay danh sach ca:neu ton tai MaCa se return Ca  do.Neu ko ton tai se tra ve tat ca cac CA
        {
            return service.laydanhsach_CA(MaCa);
        }
        public CHUYENMUC[] laydanhsach_CHUYENMUC(Int32 MaChuyenMuc)//lay danh sach chuyen muc:neu ton tai MaChuyenMuc se return chuyen muc do.
        //Neu ko ton tai se tra ve tat ca cac chuyen muc
        {
            return service.laydanhsach_CHUYENMUC(MaChuyenMuc);
        }
        public DATBAN[] laydanhsach_DATBAN(Int32 MaDatBan, DateTime TuNgay, DateTime DenNgay)//lay danh sach dat ban:
        //neu ton tai MaBan se return Ban do.Neu ko ton tai se tra ve tat ca cac ban ->theo khoang thoi gian
        {
            return service.laydanhsach_DATBAN(MaDatBan, TuNgay, DenNgay);
        }
        public LOAIHANG[] laydanhsach_LOAIHANG()
        {
            return service.laydanhsach_LOAIHANG();
        }
        public laydanhsach_LOAIHANGResult[] laydanhsach_LOAIHANG2(Int32 id)
        {
            return service.laydanhsach_LOAIHANG2(id);
        }
      public laydanhsach_HANGBANResult[] laydanhsach_HANGBAN(Int32 id)
      {
          return service.laydanhsach_HANGBAN(id);
      }
#endregion
    }
}